package com.yjd.comm.user.convert;

import java.util.ArrayList;
import java.util.List;

import com.yjd.comm.baseInfo.util.CityUtil;
import com.yjd.comm.system.enums.DictTypeEnum;
import com.yjd.comm.system.util.DictFieldModel;
import com.yjd.comm.system.util.DictFieldUtil;
import com.yjd.comm.user.model.UserDataModel;

/**
 * <b>description</b>：用户扩展信息数据转换器 <br>
 * <b>time</b>：2014-11-18上午10:52:06 <br>
 * <b>author</b>： ready likun_557@163.com
 */
public class UserDataModelConvert {
	static List<DictFieldModel> dictFieldModels = new ArrayList<DictFieldModel>();
	static {
		dictFieldModels.add(new DictFieldModel("ische",
				DictTypeEnum.project_type));

		dictFieldModels.add(new DictFieldModel("ische", DictTypeEnum.yesorno));
		dictFieldModels
				.add(new DictFieldModel("ischedai", DictTypeEnum.yesorno));
		dictFieldModels.add(new DictFieldModel("isfangdai",
				DictTypeEnum.yesorno));
		dictFieldModels.add(new DictFieldModel("isfang", DictTypeEnum.yesorno));
		dictFieldModels.add(new DictFieldModel("c_hangye",
				DictTypeEnum.comp_busy));
		dictFieldModels.add(new DictFieldModel("c_xingzhi",
				DictTypeEnum.comp_quality));
		dictFieldModels.add(new DictFieldModel("h_dengji",
				DictTypeEnum.hp_level));
		dictFieldModels
				.add(new DictFieldModel("h_leibie", DictTypeEnum.hp_type));
		dictFieldModels.add(new DictFieldModel("h_xingzhi",
				DictTypeEnum.hp_quality));
		dictFieldModels.add(new DictFieldModel("work_nianxian",
				DictTypeEnum.work_year));
		dictFieldModels.add(new DictFieldModel("work_guimo",
				DictTypeEnum.comp_scale));
		dictFieldModels.add(new DictFieldModel("work_shouru",
				DictTypeEnum.work_income));
		dictFieldModels.add(new DictFieldModel("work_class",
				DictTypeEnum.work_class));
		dictFieldModels.add(new DictFieldModel("o_type",
				DictTypeEnum.contact_type_2));
		dictFieldModels.add(new DictFieldModel("z_type",
				DictTypeEnum.contact_type_1));
		dictFieldModels.add(new DictFieldModel("iszinv", DictTypeEnum.yesorno));
		dictFieldModels.add(new DictFieldModel("hunyin",
				DictTypeEnum.marry_status));
		dictFieldModels
				.add(new DictFieldModel("xueli", DictTypeEnum.education));
	}

	public static UserDataModel convert(UserDataModel model) throws Exception {
		if (model != null) {
			DictFieldUtil.disposeModel(model, dictFieldModels);
			model.getStrMap().put("hukou",
					CityUtil.getFullCityNames(model.getHukou(), " "));
			model.getStrMap().put("city",
					CityUtil.getFullCityNames(model.getCity(), " "));
			model.getStrMap().put("work_city",
					CityUtil.getFullCityNames(model.getCity(), " "));
		}
		return model;
	}

	public static List<UserDataModel> convert(List<UserDataModel> models)
			throws Exception {
		if (models == null || models.size() == 0) {
			return models;
		}
		for (UserDataModel model : models) {
			convert(model);
		}
		return models;
	}
}
